package com.lightsaber.trade.cloth.entity.dataimport;

import java.util.LinkedHashMap;
import java.util.Map;

public enum DataimportInterfaceType {

    WebServiceSRS, InterfaceFileIVE, InterfaceFileTRS;

    public static String getNameByType(final DataimportInterfaceType type) {
        if (type == DataimportInterfaceType.WebServiceSRS) {
            return "Web Service - SRS";
        } else if (type == DataimportInterfaceType.InterfaceFileIVE) {
            return "Interface File - IVE";
        } else if (type == DataimportInterfaceType.InterfaceFileTRS) {
            return "Interface File - TRS";
        } else {
            return type.toString();
        }
    }

    public static DataimportInterfaceType getTypeByTypeName(final String typeName) {
        if (typeName.equalsIgnoreCase(DataimportInterfaceType.WebServiceSRS.toString())) {
            return DataimportInterfaceType.WebServiceSRS;
        } else if (typeName.equalsIgnoreCase(DataimportInterfaceType.InterfaceFileIVE.toString())) {
            return DataimportInterfaceType.InterfaceFileIVE;
        } else if (typeName.equalsIgnoreCase(DataimportInterfaceType.InterfaceFileTRS.toString())) {
            return DataimportInterfaceType.InterfaceFileTRS;
        } else {
            return null;
        }
    }

    public static String getTypeNameByName(final DataimportInterfaceType type) {
        if (type == DataimportInterfaceType.WebServiceSRS) {
            return DataimportInterfaceType.WebServiceSRS.toString();
        } else if (type == DataimportInterfaceType.InterfaceFileIVE) {
            return DataimportInterfaceType.InterfaceFileIVE.toString();
        } else if (type == DataimportInterfaceType.InterfaceFileTRS) {
            return DataimportInterfaceType.InterfaceFileTRS.toString();
        } else {
            return null;
        }
    }

    public static Map<String, String> list() {
        Map<String, String> map = new LinkedHashMap<String, String>();

        for (DataimportInterfaceType type : DataimportInterfaceType.values()) {
            map.put(type.toString(), getNameByType(type));
        }

        return map;
    }
}
